<template>
  <el-menu :default-openeds="opens" style="min-height: 100%; overflow-x: hidden"
           background-color="rgb(48, 65, 86)"
           text-color="#fff"
           active-text-color="#ffd04b"
           :collapse-transition="false"
           :collapse="isCollapse"
           router
  >
    <div style="height: 60px; line-height: 60px; text-align: center; padding: 0 0px">
      <b style="color: #fff" v-show="logoTextShow">智慧设备管理综合系统</b>
    </div>
<!--    <div v-for="item in menus" :key="item.menuId">
      &lt;!&ndash;  判断pid有没有 没有就是一级    &ndash;&gt;
      <div v-if="item.menuPath">
        <el-menu-item :index="item.menuPath">
          <i :class="item.menuIcon"></i>
          <span slot="title">{{item.menuName}}</span>
        </el-menu-item>
      </div>
      <div v-else>
        <el-submenu :index="item.menuId +'0'">
          <template slot="title">
            <i :class="item.menuIcon"></i>
            <span slot="title">{{item.menuName}}</span>
          </template>
          &lt;!&ndash;  遍历子级    &ndash;&gt;
          <div v-for="subItem in item.children" :key="subItem.menuId">
            <el-menu-item :index="subItem.menuPath">
              <i :class="subItem.menuIcon"></i>
              <span slot="title">{{subItem.menuName}}</span>
            </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </div>-->
    <el-menu-item index="/pandect">
        <i class="el-icon-house"></i>
        <span slot="title">总览</span>
    </el-menu-item>

    <el-submenu index="1-1">
      <template slot="title">
        <i class="el-icon-s-home"></i>
        <span slot="title">设备管理</span>
      </template>
        <el-menu-item index="EquipmentArchives">设备档案</el-menu-item>
        <el-menu-item index="devicetype">设备类型</el-menu-item>
        <el-menu-item index="placeforstorage">存放位置</el-menu-item>
    </el-submenu>

    <el-submenu index="2-1">
        <template slot="title">
         <i class="el-icon-s-home"></i>
         <span slot="title">备件管理</span>
        </template>
        <el-submenu index="2-2">
            <template slot="title">备件台账</template>
            <el-menu-item index="/ledger">备件台账</el-menu-item>
            <el-menu-item index="/sparePartTypes">备件类型</el-menu-item>
        </el-submenu>
        <el-submenu index="2-3">
            <template slot="title">库存管理</template>
            <el-menu-item index="/wareHousing">入库管理</el-menu-item>
            <el-menu-item index="/spareUse">备件领用</el-menu-item>
            <el-menu-item index="/outWareHousing">出库管理</el-menu-item>
        </el-submenu>
        <el-submenu index="2-4">
            <template slot="title">备件采购</template>
            <el-menu-item index="/spareRequisition">备件采购</el-menu-item>
        </el-submenu>
    </el-submenu>

      <el-submenu index="3-1">
          <template slot="title">
              <i class="el-icon-s-home"></i>
              <span slot="title">设备维修</span>
          </template>
      </el-submenu>

      <el-submenu index="4-1">
          <template slot="title">
              <i class="el-icon-s-home"></i>
              <span slot="title">设备保养</span>
          </template>
          <el-menu-item index="MaintenanceProgram">保养项目</el-menu-item>
          <el-menu-item index="MaintenanceLevel">保养级别</el-menu-item>
          <el-menu-item index="MaintenanceExperiencel">保养经验</el-menu-item>

      </el-submenu>

      <el-submenu index="5-1">
          <template slot="title">
              <i class="el-icon-s-home"></i>
              <span slot="title">巡检点检</span>
          </template>
      </el-submenu>

      <el-submenu index="6-1">
          <template slot="title">
              <i class="el-icon-s-home"></i>
              <span slot="title">系统设置</span>
          </template>
      </el-submenu>
  </el-menu>
</template>

<script>
export default {
  name: "Aside",
  props: {
    isCollapse: Boolean,    //控制侧边收缩
    logoTextShow: Boolean,  //后台管理文字隐藏
    // menus: Array //角色菜单数据
  },
  data(){
    return {
      //角色菜单数据
      menus: localStorage.getItem("menuList") ? JSON.parse(localStorage.getItem("menuList")) : [],
      //菜单默认展开
      opens: localStorage.getItem("menuList") ? JSON.parse(localStorage.getItem("menuList")).map(v => v.id + '') : [],
    }
  }
}
</script>

<style scoped>
/*解决收缩菜单文字不消失问题*/
.el-menu--collapse span {
  visibility: hidden;
}
</style>
